package com.binance.mbxgateway.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.binance.master.models.APIRequest;
import com.binance.master.models.APIResponse;
import com.binance.mbxgateway.api.ITradeApi;
import com.binance.mbxgateway.vo.request.GetAggTradesRequest;
import com.binance.mbxgateway.web.service.ITradeService;

@RestController
public class TradeController implements ITradeApi {

    @Autowired
    private ITradeService tradeService;

    @Override
    public APIResponse<String> getAggTrades(@RequestBody @Validated APIRequest<GetAggTradesRequest> request)
            throws Exception {
        return APIResponse.getOKJsonResult(this.tradeService.getAggTrades(request.getBody().getSymbol(),
                request.getBody().getStartTime(), request.getBody().getEndTime(), request.getBody().getLimit()));
    }

//    @Override
//    public APIResponse<Void> backfillTrades(@RequestBody @Validated APIRequest<BackfillTradesRequest> request)
//            throws Exception {
//        this.tradeService.backfillTrades(request.getBody().getSymbol(), request.getBody().getTradeId());
//        return APIResponse.getOKJsonResult();
//    }
}
